// 1.用es6的语法写单例模式
export { };

class Window {
  //存放单例的静态私有变量
  private static instance: Window;
  constructor() {

  };
  //通过单例来实现new实例的静态私有方法
  public static getInstance() {
    if (!Window.instance) {
      console.log('1  没有走缓存！');
      return Window.instance = new Window();
    };
    console.log('1  走缓存！');
    return Window.instance;
  }
}
//1 测试单例
let w1 = Window.getInstance();
let w2 = Window.getInstance();
console.log(`1 两个实例是否一样${w1==w2}`)

